﻿using iCodeStudio.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iCodeStudio.Services
{
    public class iCode_UserServices : BaseService
    {
        /// <summary>
        /// 获取所有用户
        /// </summary>
        /// <returns></returns>
        public IList<iCode_User> GetAlliCode_User()
        {
            return SqlMap.QueryForList<iCode_User>("SelectAllUser", null);
        }

        /// <summary>
        /// 获取用户实体
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public iCode_User GetUserByid(int userID)
        {
            return (iCode_User)SqlMap.QueryForObject("SelectByUserId", userID);
        }

        public iCode_User GetUserByAccount(string userAccount) 
        {
            return (iCode_User)SqlMap.QueryForObject("SelectByUserId", userAccount);
        }

        /// <summary>
        /// 添加一个用户
        /// </summary>
        /// <param name="user"></param>
        public void AddUser(iCode_User user)
        {
            SqlMap.Insert("InsertUser", user);
        }

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="user"></param>
        public void UpdateUser(iCode_User user)
        {
            SqlMap.Update("UpdateUser", user);
        }

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="user"></param>
        public void DeleteUser(iCode_User user)
        {
            SqlMap.Delete("DeleteUser", user);
        }
    }
}
